<template>
  <!-- 货主搜索 -->
  <base-table-select v-model="owner" :disabled="disabled" placeholder="请选择货主" class="my-form_input" :api-obj="deviceObj" :params="params" :table-width="500" :props="deviceProps" @change="change">
    <el-table-column prop="name" label="货主名称" min-width="145" align="center" />
    <el-table-column prop="contactName" label="联系人" width="100" align="center" />
    <el-table-column prop="contactPhone" label="联系人电话" width="100" align="center" />
  </base-table-select>
</template>

<script>
import { reqCondition } from '@/api/module/owner-manage.js'
export default {
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    param: {
      type: Object,
      default: () => {
        return {}
      }
    },
    data: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      owner: {},
      deviceObj: reqCondition, // 请求接口
      deviceProps: {
        label: 'name',
        value: 'id',
        keyword: 'name',
        page: 'page',
        pageSize: 'size'
      },
      params: {
        // internalCargoOwner: true, //查询所有的内部货主
        valid: true
        // status: 'PASSED,UPDATE_FINANCE_PENDING'
      }
    }
  },
  watch: {
    param: {
      handler() {
        Object.assign(this.params, this.param)
      },
      deep: true,
      immediate: true
    },
    data: {
      handler(val) {
        this.owner = val.id ? Object.assign({}, this.owner, val) : {}
        // console.log(this.owner)
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    change() {
      this.$emit('change', this.owner)
    },
    clear() {
      this.owner = {}
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
